<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> 我的个人入口
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">			
            <div class="handle-box">
                <el-button type="primary" v-if="isget" icon="el-icon-magic-stick" class="handle-del mr10" @click="handleGet">获取短信验证码</el-button>
                <el-input v-model="query.code" placeholder="请输入短信验证码" class="handle-input mr10"></el-input>
                <el-button type="primary" icon="el-icon-tableware" @click="handleLogin">进入</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import { iclist } from '../../api/index';
import md5 from 'js-md5';
import tool from '../../utils/tools';

export default {
    name: 'self-portal',
    data() {
        return {
            query: {
                type: '',
                code: ''
            },
			isget: true
        };
    },
    created() {
        // this.getData();
    },
	filters:{
		timeas(val){
			if(val=='') return ''
			return tool.stamp2datetime(val,1000).substring(0,10)
		}
	},
    methods: {
		// 获取 easy-mock 的模拟数据
		getData() {
			if(this.auth===1){
				iclist(this.query).then(res => {
				    this.tableData = res.list;
					if(res.pageTotal){
						this.pageTotal = res.pageTotal || res.list.length;
					}
				});
			}else{
				console.error('您还没进行身份认证');
			}
		},
        // 保存编辑
        saveEdit() {
            this.editVisible = false;
			if(md5(this.form.name+'-'+this.form.pass) == '31d28a724b5b760454962699fa18e9d2'){
				this.auth = 1;
				this.getData();
				this.$message.success(`认证成功`);
			}else{
				this.$message.error(`认证失败`);
			}
        },
        // 获取验证码
        handleGet(val) {
			this.$message.success(`验证码已发送成功`)
			this.isget = false
        },
		// 触发搜索按钮
		handleLogin() {
			if(md5(this.query.code) == 'e3433dfd174e9ca70ce62023d12b240e'){
				this.$message.success(`认证成功，正在登录中...`);
				this.$router.push("/self-ic?id=60");
			}else{
				this.$message.error(`认证失败`);
			}
		},
		// 多选操作
		handleSelectionChange(val) {
		    this.multipleSelection = val;
		},
    },mounted(){
		if(this.auth === 0){
			// this.editVisible = true;
		}
	}
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
</style>
